package behavioral.observer.custom;

import java.util.ArrayList;
import java.util.List;

public class Button {
    private List<OBserver> observers;

    private String msg;
    private String val;


    public Button() {
        observers = new ArrayList();
    }

    public void registerOb(OBserver ob) {
        observers.add(ob);
    }

    public void removeOb(OBserver ob) {
        int i = observers.indexOf(ob);
        if (i != -1) {
            observers.remove(i);
        }
    }

    public void notifyObs() {
        for(OBserver ob : observers) {
            ob.update(msg, val);
        }
    }


    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setVal(String val) {
        this.val = val;
    }
}
